﻿
using System;
using Excel.Expressions;
using Excel.Expressions.Compiler;
using Expressions.Compiler;
using Expressions.Compiler.Internal;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Tests
{
    /// <summary>
    /// Summary description for Expression
    /// </summary>
    [TestClass]
    public class Test1
    {
        public Test1()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        [TestMethod]
        public void Test1_1()
        {
            // Forward declarations
            Nonterminal<char> real_literal = "real-literal";
            Nonterminal<char> exponent_part = "exponent-part";
            Nonterminal<char> sign = "sign";
            Nonterminal<char> real_type_suffix = "real-type-suffix";
            Nonterminal<char> decimal_digits = "decimal-digits";
            Nonterminal<char> decimal_digit = "decimal-digit";

            /*
            real-literal::
                sign[opt] decimal-digits . decimal-digits exponent-part[opt] real-type-suffix[opt]
                sign[opt] . decimal-digits exponent-part[opt] real-type-suffix[opt] 
                sign[opt] decimal-digits exponent-part real-type-suffix[opt] 
                sign[opt] decimal-digits real-type-suffix 
            */
            real_literal.Definition = new Rules<char>
            {
                () => sign[true] + decimal_digits[false] + '.' + decimal_digits[false] + exponent_part[true] + real_type_suffix[true],
                () => sign[true] + '.' + decimal_digits[false] + exponent_part[true] + real_type_suffix[true],
                () => sign[true] + decimal_digits[false] + exponent_part[false] + real_type_suffix[true],
                () => sign[true] + decimal_digits[false] + real_type_suffix[false]
            };

            /*
            exponent-part::
                e sign[opt] decimal-digits 
                E sign[opt] decimal-digits 
            */
            exponent_part.Definition = new Rules<char>
            {
                () => 'e' + sign[true] + decimal_digits[false],
                () => 'E' + sign[true] + decimal_digits[false]
            };

            /*
            sign:: one of
                + - 
            */
            sign.Definition = new Rules<char>
            {
                () => '+',
                () => '-'
            };

            /*
            real-type-suffix:: one of
                F f  
             */
            real_type_suffix.Definition = new Rules<char>
            {
                () => 'F',
                () => 'f'
            };

            /*
            decimal-digits::
                decimal-digit 
                decimal-digits decimal-digit 
            */
            decimal_digits.Definition = new Rules<char>
            {
                () => decimal_digit[false] + decimal_digits[true]
            };

            /*
            decimal-digit:: one of
                0 1 2 3 4 5 6 7 8 9 
            */
            decimal_digit.Definition = new Rules<char>
            {
                () => '0',
                () => '1',
                () => '2',
                () => '3',
                () => '4',
                () => '5',
                () => '6',
                () => '7',
                () => '8',
                () => '9'
            };

            Terminal<char>[] _ = { '(', ')', '+', '-', '*', '/' };

            Nonterminal<char> E = "E";
            Nonterminal<char> Eopt = "E'";

            Nonterminal<char> T = "T";
            Nonterminal<char> Topt = "T'";

            Nonterminal<char> F = "F";
            Nonterminal<char> N = "N";

            E.Definition = new Rules<char>
            {
                () => T[false] + Eopt[true]
            };

            T.Definition = new Rules<char>
            {
                () => F[false] + Topt[true]
            };

            F.Definition = new Rules<char>
            {
                () => N[false],
                () => '(' + E[false] + ')'
            };

            N.Definition = new Rules<char>
            {
                () => real_literal[false]
            };

            Eopt.Definition = new Rules<char>
            {
                () => '+' + E[false],
                () => '-' + E[false]
            };

            Topt.Definition = new Rules<char>
            {
                () => '*' + T[false],
                () => '/' + T[false]
            };

            Nonterminal<char> grammar = "G";

            grammar.Definition = new Rules<char> 
            {
                () => E[false] + Terminal<char>.Default
            };

            Entity<char> target = grammar;
            grammar.Initialize();
            grammar.Validate();
            Parser<char> input = "-.5e-2f--12e5))".ToCharArray();
            bool expected = true;
            bool actual = target.Parse(input) == false;
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void Test1_2()
        {
            // Forward declarations
            Nonterminal<char> real_literal = "real-literal";
            Nonterminal<char> exponent_part = "exponent-part";
            Nonterminal<char> sign = "sign";
            Nonterminal<char> real_type_suffix = "real-type-suffix";
            Nonterminal<char> decimal_digits = "decimal-digits";
            Nonterminal<char> decimal_digit = "decimal-digit";

            /*
            real-literal::
                sign[opt] decimal-digits . decimal-digits exponent-part[opt] real-type-suffix[opt]
                sign[opt] . decimal-digits exponent-part[opt] real-type-suffix[opt] 
                sign[opt] decimal-digits exponent-part real-type-suffix[opt] 
                sign[opt] decimal-digits real-type-suffix 
            */
            real_literal.Definition = new Rules<char>
            {
                () => sign[true] + decimal_digits[false] + '.' + decimal_digits[false] + exponent_part[true] + real_type_suffix[true],
                () => sign[true] + '.' + decimal_digits[false] + exponent_part[true] + real_type_suffix[true],
                () => sign[true] + decimal_digits[false] + exponent_part[false] + real_type_suffix[true],
                () => sign[true] + decimal_digits[false] + real_type_suffix[false]
            };

            /*
            exponent-part::
                e sign[opt] decimal-digits 
                E sign[opt] decimal-digits 
            */
            exponent_part.Definition = new Rules<char>
            {
                () => 'e' + sign[true] + decimal_digits[false],
                () => 'E' + sign[true] + decimal_digits[false]
            };

            /*
            sign:: one of
                + - 
            */
            sign.Definition = new Rules<char>
            {
                () => '+',
                () => '-'
            };

            /*
            real-type-suffix:: one of
                F f  
             */
            real_type_suffix.Definition = new Rules<char>
            {
                () => 'F',
                () => 'f'
            };

            /*
            decimal-digits::
                decimal-digit 
                decimal-digits decimal-digit 
            */
            decimal_digits.Definition = new Rules<char>
            {
                () => decimal_digit[false] + decimal_digits[true]
            };

            /*
            decimal-digit:: one of
                0 1 2 3 4 5 6 7 8 9 
            */
            decimal_digit.Definition = new Rules<char>
            {
                () => '0',
                () => '1',
                () => '2',
                () => '3',
                () => '4',
                () => '5',
                () => '6',
                () => '7',
                () => '8',
                () => '9'
            };

            Terminal<char>[] _ = { '(', ')', '+', '-', '*', '/' };

            Nonterminal<char> E = "E";
            Nonterminal<char> Eopt = "E'";

            Nonterminal<char> T = "T";
            Nonterminal<char> Topt = "T'";

            Nonterminal<char> F = "F";
            Nonterminal<char> N = "N";

            E.Definition = new Rules<char>
            {
                () => T[false] + Eopt[true]
            };

            T.Definition = new Rules<char>
            {
                () => F[false] + Topt[true]
            };

            F.Definition = new Rules<char>
            {
                () => N[false],
                () => '(' + E[false] + ')'
            };

            N.Definition = new Rules<char>
            {
                () => real_literal[false]
            };

            Eopt.Definition = new Rules<char>
            {
                () => '+' + E[false],
                () => '-' + E[false]
            };

            Topt.Definition = new Rules<char>
            {
                () => '*' + T[false],
                () => '/' + T[false]
            };

            Nonterminal<char> grammar = "G";

            grammar.Definition = new Rules<char> 
            {
                () => E[false] + Terminal<char>.Default
            };

            Entity<char> target = grammar;
            grammar.Initialize();
            grammar.Validate();
            Parser<char> input = "-.5e-2f--12e".ToCharArray();
            bool expected = true;
            bool actual = target.Parse(input) == false;
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void Test1_3()
        {
            // Forward declarations
            Nonterminal<char> real_literal = "real-literal";
            Nonterminal<char> exponent_part = "exponent-part";
            Nonterminal<char> sign = "sign";
            Nonterminal<char> real_type_suffix = "real-type-suffix";
            Nonterminal<char> decimal_digits = "decimal-digits";
            Nonterminal<char> decimal_digit = "decimal-digit";

            /*
            real-literal::
                sign[opt] decimal-digits . decimal-digits exponent-part[opt] real-type-suffix[opt]
                sign[opt] . decimal-digits exponent-part[opt] real-type-suffix[opt] 
                sign[opt] decimal-digits exponent-part real-type-suffix[opt] 
                sign[opt] decimal-digits real-type-suffix 
            */
            real_literal.Definition = new Rules<char>
            {
                () => sign[true] + decimal_digits[false] + '.' + decimal_digits[false] + exponent_part[true] + real_type_suffix[true],
                () => sign[true] + '.' + decimal_digits[false] + exponent_part[true] + real_type_suffix[true],
                () => sign[true] + decimal_digits[false] + exponent_part[false] + real_type_suffix[true],
                () => sign[true] + decimal_digits[false] + real_type_suffix[false]
            };

            /*
            exponent-part::
                e sign[opt] decimal-digits 
                E sign[opt] decimal-digits 
            */
            exponent_part.Definition = new Rules<char>
            {
                () => 'e' + sign[true] + decimal_digits[false],
                () => 'E' + sign[true] + decimal_digits[false]
            };

            /*
            sign:: one of
                + - 
            */
            sign.Definition = new Rules<char>
            {
                () => '+',
                () => '-'
            };

            /*
            real-type-suffix:: one of
                F f  
             */
            real_type_suffix.Definition = new Rules<char>
            {
                () => 'F',
                () => 'f'
            };

            /*
            decimal-digits::
                decimal-digit 
                decimal-digits decimal-digit 
            */
            decimal_digits.Definition = new Rules<char>
            {
                () => decimal_digit[false] + decimal_digits[true]
            };

            /*
            decimal-digit:: one of
                0 1 2 3 4 5 6 7 8 9 
            */
            decimal_digit.Definition = new Rules<char>
            {
                () => '0',
                () => '1',
                () => '2',
                () => '3',
                () => '4',
                () => '5',
                () => '6',
                () => '7',
                () => '8',
                () => '9'
            };

            Terminal<char>[] _ = { '(', ')', '+', '-', '*', '/' };

            Nonterminal<char> E = "E";
            Nonterminal<char> Eopt = "E'";

            Nonterminal<char> T = "T";
            Nonterminal<char> Topt = "T'";

            Nonterminal<char> F = "F";
            Nonterminal<char> N = "N";

            E.Definition = new Rules<char>
            {
                () => T[false] + Eopt[true]
            };

            T.Definition = new Rules<char>
            {
                () => F[false] + Topt[true]
            };

            F.Definition = new Rules<char>
            {
                () => N[false],
                () => '(' + E[false] + ')'
            };

            N.Definition = new Rules<char>
            {
                () => real_literal[false]
            };

            Eopt.Definition = new Rules<char>
            {
                () => '+' + E[false],
                () => '-' + E[false]
            };

            Topt.Definition = new Rules<char>
            {
                () => '*' + T[false],
                () => '/' + T[false]
            };

            Nonterminal<char> grammar = "G";

            grammar.Definition = new Rules<char> 
            {
                () => E[false] + Terminal<char>.Default
            };

            grammar.Initialize();
            grammar.Validate();

            Entity<char> target = grammar;

            Parser<char> input = "-.5e-2f--12e5".ToCharArray();
            bool expected = true;
            bool actual = target.Parse(input) == true;
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void Test1_4()
        {
            // Forward declarations
            Nonterminal<char> real_literal = "real-literal";
            Nonterminal<char> exponent_part = "exponent-part";
            Nonterminal<char> sign = "sign";
            Nonterminal<char> real_type_suffix = "real-type-suffix";
            Nonterminal<char> decimal_digits = "decimal-digits";
            Nonterminal<char> decimal_digit = "decimal-digit";

            /*
            real-literal::
                sign[opt] decimal-digits . decimal-digits exponent-part[opt] real-type-suffix[opt]
                sign[opt] . decimal-digits exponent-part[opt] real-type-suffix[opt] 
                sign[opt] decimal-digits exponent-part real-type-suffix[opt] 
                sign[opt] decimal-digits real-type-suffix 
            */
            real_literal.Definition = new Rules<char>
            {
                () => sign[true] + decimal_digits[false] + '.' + decimal_digits[false] + exponent_part[true] + real_type_suffix[true],
                () => sign[true] + '.' + decimal_digits[false] + exponent_part[true] + real_type_suffix[true],
                () => sign[true] + decimal_digits[false] + exponent_part[false] + real_type_suffix[true],
                () => sign[true] + decimal_digits[false] + real_type_suffix[false]
            };

            /*
            exponent-part::
                e sign[opt] decimal-digits 
                E sign[opt] decimal-digits 
            */
            exponent_part.Definition = new Rules<char>
            {
                () => 'e' + sign[true] + decimal_digits[false],
                () => 'E' + sign[true] + decimal_digits[false]
            };

            /*
            sign:: one of
                + - 
            */
            sign.Definition = new Rules<char>
            {
                () => '+',
                () => '-'
            };

            /*
            real-type-suffix:: one of
                F f  
             */
            real_type_suffix.Definition = new Rules<char>
            {
                () => 'F',
                () => 'f'
            };

            /*
            decimal-digits::
                decimal-digit 
                decimal-digits decimal-digit 
            */
            decimal_digits.Definition = new Rules<char>
            {
                () => decimal_digit[false] + decimal_digits[true]
            };

            /*
            decimal-digit:: one of
                0 1 2 3 4 5 6 7 8 9 
            */
            decimal_digit.Definition = new Rules<char>
            {
                () => '0',
                () => '1',
                () => '2',
                () => '3',
                () => '4',
                () => '5',
                () => '6',
                () => '7',
                () => '8',
                () => '9'
            };

            Terminal<char>[] _ = { '(', ')', '+', '-', '*', '/' };

            Nonterminal<char> E = "E";
            Nonterminal<char> Eopt = "E'";

            Nonterminal<char> T = "T";
            Nonterminal<char> Topt = "T'";

            Nonterminal<char> F = "F";
            Nonterminal<char> N = "N";

            E.Definition = new Rules<char>
            {
                () => T[false] + Eopt[true]
            };

            T.Definition = new Rules<char>
            {
                () => F[false] + Topt[true]
            };

            F.Definition = new Rules<char>
            {
                () => N[false],
                () => '(' + E[false] + ')'
            };

            N.Definition = new Rules<char>
            {
                () => real_literal[false]
            };

            Eopt.Definition = new Rules<char>
            {
                () => '+' + E[false],
                () => '-' + E[false]
            };

            Topt.Definition = new Rules<char>
            {
                () => '*' + T[false],
                () => '/' + T[false]
            };

            Nonterminal<char> grammar = "G";

            grammar.Definition = new Rules<char> 
            {
                () => E[false] + "--12e".ToCharArray() + Terminal<char>.Default
            };

            grammar.Initialize();
            grammar.Validate();

            Entity<char> target = grammar;

            Parser<char> input = "-.5e-2f--12e".ToCharArray();
            bool expected = true;
            bool actual = target.Parse(input) == true;
            Assert.AreEqual(expected, actual);
        }


        [TestMethod]
        public void Test1_5()
        {
            // Forward declarations
            Nonterminal<char> real_literal = "real-literal";
            Nonterminal<char> exponent_part = "exponent-part";
            Nonterminal<char> sign = "sign";
            Nonterminal<char> real_type_suffix = "real-type-suffix";
            Nonterminal<char> decimal_digits = "decimal-digits";
            Nonterminal<char> decimal_digit = "decimal-digit";

            /*
            real-literal::
                sign[opt] decimal-digits . decimal-digits exponent-part[opt] real-type-suffix[opt]
                sign[opt] . decimal-digits exponent-part[opt] real-type-suffix[opt] 
                sign[opt] decimal-digits exponent-part real-type-suffix[opt] 
                sign[opt] decimal-digits real-type-suffix 
            */
            real_literal.Definition = new Rules<char>
            {
                () => sign[true] + decimal_digits[false] + '.' + decimal_digits[false] + exponent_part[true] + real_type_suffix[true],
                () => sign[true] + '.' + decimal_digits[false] + exponent_part[true] + real_type_suffix[true],
                () => sign[true] + decimal_digits[false] + exponent_part[false] + real_type_suffix[true],
                () => sign[true] + decimal_digits[false] + real_type_suffix[false]
            };

            /*
            exponent-part::
                e sign[opt] decimal-digits 
                E sign[opt] decimal-digits 
            */
            exponent_part.Definition = new Rules<char>
            {
                () => 'e' + sign[true] + decimal_digits[false],
                () => 'E' + sign[true] + decimal_digits[false]
            };

            /*
            sign:: one of
                + - 
            */
            sign.Definition = new Rules<char>
            {
                () => '+',
                () => '-'
            };

            /*
            real-type-suffix:: one of
                F f  
             */
            real_type_suffix.Definition = new Rules<char>
            {
                () => 'F',
                () => 'f'
            };

            /*
            decimal-digits::
                decimal-digit 
                decimal-digits decimal-digit 
            */
            decimal_digits.Definition = new Rules<char>
            {
                () => decimal_digit[false] + decimal_digits[true]
            };

            /*
            decimal-digit:: one of
                0 1 2 3 4 5 6 7 8 9 
            */
            decimal_digit.Definition = new Rules<char>
            {
                () => '0',
                () => '1',
                () => '2',
                () => '3',
                () => '4',
                () => '5',
                () => '6',
                () => '7',
                () => '8',
                () => '9'
            };

            Terminal<char>[] _ = { '(', ')', '+', '-', '*', '/' };

            Nonterminal<char> E = "E";
            Nonterminal<char> Eopt = "E'";

            Nonterminal<char> T = "T";
            Nonterminal<char> Topt = "T'";

            Nonterminal<char> F = "F";
            Nonterminal<char> N = "N";

            E.Definition = new Rules<char>
            {
                () => T[false] + Eopt[true]
            };

            T.Definition = new Rules<char>
            {
                () => F[false] + Topt[true]
            };

            F.Definition = new Rules<char>
            {
                () => N[false],
                () => '(' + E[false] + ')'
            };

            N.Definition = new Rules<char>
            {
                () => real_literal[false]
            };

            Eopt.Definition = new Rules<char>
            {
                () => '+' + E[false],
                () => '-' + E[false]
            };

            Topt.Definition = new Rules<char>
            {
                () => '*' + T[false],
                () => '/' + T[false]
            };

            Nonterminal<char> grammar = "G";

            grammar.Definition = new Rules<char> 
            {
                () => E[false]
            };

            grammar.Initialize();
            grammar.Validate();

            Entity<char> target = grammar;

            Parser<char> input = "-.5e-2f--12e".ToCharArray();
            bool expected = true;
            bool actual = target.Parse(input) == true;
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void Test1_6()
        {
            CellExpression expression = Text.Parse("6+((7-2)/5-9)*0.5-2+1");
            System.Linq.Expressions.Expression<Func<double>> ex = () => expression.Eval();
            Func<double> func = ex.Compile();
            double result = func();
            bool expected = true;
            bool actual = result == 1.0;
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void Test1_7()
        {
            try
            {
                Nonterminal<char> n = "n123";
                Nonterminal<char> q = "n123";

                n.Definition = new Rules<char>()
                {
                    () => n[false]
                };
                n.Initialize();
                n.Validate();
            }
            catch (NotSupportedException ex)
            {
                Assert.IsNotNull(ex.Message);
                return;
            }
            Assert.Fail();
        }

        [TestMethod]
        public void Test1_8()
        {
            try
            {
                Nonterminal<char> n = "n";
                Nonterminal<char> q = "n";
                n.Definition = new Rules<char>()
                {
                    () => n[true]
                };
                n.Initialize();
                n.Validate();
            }
            catch (NotSupportedException ex)
            {
                Assert.IsNotNull(ex.Message);
                return;
            }
            Assert.Fail();
        }

        [TestMethod]
        public void Test1_9()
        {
            try
            {
                Nonterminal<char> n = "n";
                Nonterminal<char> q = "n";

                n.Definition = new Rules<char>()
                {
                    () => q[false] + n[false]
                };
                n.Initialize();
                n.Validate();
            }
            catch (NotSupportedException ex)
            {
                Assert.IsNotNull(ex.Message);
                return;
            }
            Assert.Fail();
        }

        [TestMethod]
        public void Test1_10()
        {
            bool exception = false;
            try
            {
                Nonterminal<char> n = "n3434";
                Nonterminal<char> q = "n3434";

                n.Definition = new Rules<char>()
                {
                    () => q[false] + n[true]
                };
                n.Initialize();
                n.Validate();
            }
            catch (NotSupportedException)
            {
                exception = true;
            }
            if (!exception)
            {
                Assert.Fail();
            }
        }

        [TestMethod]
        public void Test1_11()
        {
            bool exception = false;
            try
            {
                Nonterminal<char> n = "346n";
                Nonterminal<char> q = "346n";

                n.Definition = new Rules<char>()
                {
                    () => q[true] + n[false]
                };
                n.Initialize();
                n.Validate();
            }
            catch (NotSupportedException)
            {
                exception = true;
            }
            if (!exception)
            {
                Assert.Fail();
            }
        }

        [TestMethod]
        public void Test1_12()
        {
            bool exception = false;
            try
            {
                Nonterminal<char> n = "n4466";
                Nonterminal<char> q = "n4466";

                n.Definition = new Rules<char>()
                {
                    () => q[true] + n[true]
                };
                n.Initialize();
                n.Validate();
            }
            catch (NotSupportedException)
            {
                exception = true;
            }
            if (!exception)
            {
                Assert.Fail();
            }
        }
        [TestMethod]
        public void Test1_13()
        {
            bool exception = false;
            try
            {
                Nonterminal<char> n = "n665";
                Nonterminal<char> q = "n665";

                n.Definition = new Rules<char>()
                {
                    () => q[false] + n[false]
                };
                q.Definition = new Rules<char>()
                {
                    () => n[false]
                };
                n.Initialize();
                n.Validate();
            }
            catch (NotSupportedException)
            {
                exception = true;
            }
            if (!exception)
            {
                Assert.Fail();
            }
        }

        [TestMethod]
        public void Test1_14()
        {
            bool exception = false;
            try
            {
                Nonterminal<char> n = "n234";
                Nonterminal<char> q = "n234";

                n.Definition = new Rules<char>()
                {
                    () => q[false] + n[true]
                };
                q.Definition = new Rules<char>()
                {
                    () => n[false]
                };
                n.Initialize();
                n.Validate();
            }
            catch (NotSupportedException)
            {
                exception = true;
            }
            if (!exception)
            {
                Assert.Fail();
            }
        }

        [TestMethod]
        public void Test1_14_1()
        {
            try
            {
                Nonterminal<char> n = "n[t]";
                Nonterminal<char> q = "q[t]";

                n.Definition = new Rules<char>()
                {
                    () => q[false] + n[true]
                };
                q.Definition = new Rules<char>()
                {
                    () => '(' + n[true]
                };
                q.Initialize();
                q.Validate();
            }
            catch (NotSupportedException)
            {
                Assert.Fail();
            }
        }

        [TestMethod]
        public void Test1_14_2()
        {
            try
            {
                Nonterminal<char> n = "n[t]";
                Nonterminal<char> q = "q[t]";
                n.Definition = new Rules<char>()
                {
                    () => q[false] + n[true]
                };
                q.Definition = new Rules<char>()
                {
                    () => n[false]
                };
                q.Initialize();
                q.Validate();
                Assert.Fail();
            }
            catch (NotSupportedException)
            {
            }
        }


        [TestMethod]
        public void Test1_14_3()
        {
            try
            {
                Nonterminal<char> n = "n[t]";
                Nonterminal<char> q = "q[t]";
                n.Definition = new Rules<char>()
                {
                    () => q[false] + n[true]
                };
                q.Definition = new Rules<char>()
                {
                    () => n[false] + ')'
                };
                q.Initialize();
                q.Validate();
                Assert.Fail();
            }
            catch (NotSupportedException)
            {
            }
        }

        [TestMethod]
        public void Test1_14_4()
        {
            try
            {
                Nonterminal<char> n = "n[t]";
                Nonterminal<char> q = "q[t]";
                Nonterminal<char> p = "p[t]";
                n.Definition = new Rules<char>()
                {
                    () => 'n' + q[false]
                };
                q.Definition = new Rules<char>()
                {
                    () => 'q' + p[false]
                };
                p.Definition = new Rules<char>()
                {
                    () => 'p' + n[false]
                };
                q.Initialize();
                q.Validate();
                Assert.Fail();
            }
            catch (NotSupportedException)
            {
            }
        }

        [TestMethod]
        public void Test1_14_5()
        {
            try
            {
                Nonterminal<char> n = "n[t]";
                Nonterminal<char> q = "q[t]";
                Nonterminal<char> p = "p[t]";
                n.Definition = new Rules<char>()
                {
                    () => 'n' + q[true]
                };
                q.Definition = new Rules<char>()
                {
                    () => 'q' + p[false]
                };
                p.Definition = new Rules<char>()
                {
                    () => 'p' + n[false]
                };
                q.Initialize();
                q.Validate();
            }
            catch (NotSupportedException)
            {
                Assert.Fail();
            }
        }

        [TestMethod]
        public void Test1_14_6()
        {
            try
            {
                Nonterminal<char> n = "n[t]";
                Nonterminal<char> q = "q[t]";
                Nonterminal<char> p = "p[t]";
                n.Definition = new Rules<char>()
                {
                    () => 'n' + q[true],
                    () => 'n' + q[false]
                };
                q.Definition = new Rules<char>()
                {
                    () => 'q' + p[false]
                };
                p.Definition = new Rules<char>()
                {
                    () => 'p' + n[false]
                };
                q.Initialize();
                q.Validate();
                Assert.Fail();
            }
            catch (NotSupportedException)
            {
            }
        }

        [TestMethod]
        public void Test1_14_7()
        {
            try
            {
                Nonterminal<char> n = "n[t]";
                Nonterminal<char> q = "q[t]";
                Nonterminal<char> p = "p[t]";
                n.Definition = new Rules<char>()
                {
                    () => 'n' + q[false],
                };
                q.Definition = new Rules<char>()
                {
                    () => 'q' + p[false]
                };
                p.Definition = new Rules<char>()
                {
                    () => 'p' + n[true]
                };
                q.Initialize();
                q.Validate();
            }
            catch (NotSupportedException)
            {
                Assert.Fail();
            }
        }

        [TestMethod]
        public void Test1_14_8()
        {
            try
            {
                Nonterminal<char> n = "n[t]";
                Nonterminal<char> q = "q[t]";
                Nonterminal<char> p = "p[t]";
                n.Definition = new Rules<char>()
                {
                    () => 'n' + q[false],
                };
                q.Definition = new Rules<char>()
                {
                    () => 'q' + p[false]
                };
                p.Definition = new Rules<char>()
                {
                    () => 'p' + n[true],
                    () => 'p' + n[false]
                };
                q.Initialize();
                q.Validate();
                Assert.Fail();
            }
            catch (NotSupportedException)
            {
            }
        }

        public void Test1_14_9()
        {
            try
            {
                Nonterminal<char> n = "n[t]";
                Nonterminal<char> q = "q[t]";
                Nonterminal<char> p = "p[t]";
                n.Definition = new Rules<char>()
                {
                    () => 'n' + q[false],
                };
                q.Definition = new Rules<char>()
                {
                    () => 'q' + p[false],
                    () => 'q' + n[true]
                };
                p.Definition = new Rules<char>()
                {
                    () => 'p' + n[true],
                    () => 'p' + n[false]
                };
                q.Initialize();
                q.Validate();
                Assert.Fail();
            }
            catch (NotSupportedException)
            {
            }
        }


        public void Test1_14_10()
        {
            try
            {
                Nonterminal<char> n = "n[t]";
                Nonterminal<char> q = "q[t]";
                Nonterminal<char> p = "p[t]";
                n.Definition = new Rules<char>()
                {
                    () => 'n' + q[false],
                };
                q.Definition = new Rules<char>()
                {
                    () => 'q' + p[false],
                    () => 'q' + p[true]
                };
                p.Definition = new Rules<char>()
                {
                    () => 'p' + n[false]
                };
                q.Initialize();
                q.Validate();
                Assert.Fail();
            }
            catch (NotSupportedException)
            {
            }
        }


        public void Test1_14_11()
        {
            try
            {
                Nonterminal<char> n = "n[t]";
                Nonterminal<char> q = "q[t]";
                Nonterminal<char> p = "p[t]";
                n.Definition = new Rules<char>()
                {
                    () => 'n' + q[true],
                };
                q.Definition = new Rules<char>()
                {
                    () => 'q' + p[false],
                    () => 'q' + p[true]
                };
                p.Definition = new Rules<char>()
                {
                    () => 'p' + n[false]
                };
                q.Initialize();
                q.Validate();
            }
            catch (NotSupportedException)
            {
                Assert.Fail();
            }
        }

        [TestMethod]
        public void Test1_15()
        {
            bool exception = false;
            try
            {
                Nonterminal<char> n = "n445";
                Nonterminal<char> q = "n445";

                n.Definition = new Rules<char>()
                {
                    () => q[true] + n[false]
                };
                q.Definition = new Rules<char>()
                {
                    () => n[false]
                };
                n.Initialize();
                n.Validate();
            }
            catch (NotSupportedException)
            {
                exception = true;
            }
            if (!exception)
            {
                Assert.Fail();
            }
        }

        [TestMethod]
        public void Test1_16()
        {
            bool exception = false;
            try
            {
                Nonterminal<char> n = "n213";
                Nonterminal<char> q = "n213";

                n.Definition = new Rules<char>()
                {
                    () => q[true] + n[true]
                };
                q.Definition = new Rules<char>()
                {
                    () => n[false]
                };
                n.Initialize();
                n.Validate();
            }
            catch (NotSupportedException)
            {
                exception = true;
            }
            if (!exception)
            {
                Assert.Fail();
            }
        }

        [TestMethod]
        public void Test1_17()
        {
            bool exception = false;
            try
            {
                Nonterminal<char> n = "n986";
                Nonterminal<char> q = "n986";

                n.Definition = new Rules<char>()
                {
                    () => null
                };
                n.Initialize();
                n.Validate();
            }
            catch (NotSupportedException)
            {
                exception = true;
            }
            if (!exception)
            {
                Assert.Fail();
            }
        }

        [TestMethod]
        public void Test1_18()
        {
            bool exception = false;
            try
            {
                Nonterminal<char> n = "n3344";
                Nonterminal<char> q = "n3344";

                n.Definition = new Rules<char>()
                {
                    () => new Tokens<char>()
                };
                n.Initialize();
                n.Validate();
            }
            catch (NotSupportedException)
            {
                exception = true;
            }
            if (!exception)
            {
                Assert.Fail();
            }
        }

        [TestMethod]
        public void Test1_19()
        {
            bool exception = false;
            try
            {
                Nonterminal<char> n = "n9867";
                Nonterminal<char> q = "n9867";
                Tokens<char> tokens = new Tokens<char>();
                Rule<char> rule = new Rule<char>(n, () => tokens);
                n.Definition = new Rules<char>()
                {
                    () => n[true]
                };
                n.Initialize();
                n.Validate();
            }
            catch (NotSupportedException)
            {
                exception = true;
            }
            if (!exception)
            {
                Assert.Fail();
            }
        }
    }
}
